using System;
using System.Windows.Forms;
using InfoExpress.HIV.WinApp.Utils;
using InfoExpress.WinApp.Utils;

namespace InfoExpress.HIV.WinApp.Popups
{
  public partial class FrmChangePassword : DevExpress.XtraEditors.XtraForm
  {
    public FrmChangePassword()
    {
      InitializeComponent();
    }

    private void btnOK_Click(object sender, EventArgs e)
    {
      if (dxValidationProvider.Validate())
      {
        try
        {
          if (GlobalCache.Permission.ChangePassword(txtOldPassword.Text, txtNewPassword.Text))
          {
            UIUtils.ShowInformationMessage(Constants.MsgInfoChangePwd_001);
            DialogResult = DialogResult.OK;
            Close();
          }
          else
          {
            UIUtils.ShowErrorMessage(Constants.MsgErrChangePwd_001);
          }
        }
        catch (Exception)
        {
          UIUtils.ShowErrorMessage(Constants.MsgErrChangePwd_002);
        }
      }
    }
  }
}